package graphics;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.util.List;


public class ExplosionMainParticle extends Particle{

	
	
	public ExplosionMainParticle(int x, int y) {
		this(x, y, 0, 0);		
	}

	public ExplosionMainParticle(int x, int y, int spdx, int spdy) {
		super(x, y, spdx, spdy);
		lifetime=100;
		particleSize = lifetime*200;
		
		setImage("smoke5.png");
	
	}
	
	public void nextFrame(List<Particle> pList){
		lifetime--;
		if(isDead())
			pList.remove(this);
		posx = posx + spdx;
		posy = posy + spdy;
		spdy=spdy+50;
		particleSize = lifetime * 200;
	}
	
	public void paint(Point screenOffset, int zoomDivider, Graphics g){
		BufferedImage im = (BufferedImage)ImageHandler.getInstance().getImage(imageName);
		Graphics2D g2d = (Graphics2D)g;
		AffineTransform at = new AffineTransform();
		at.translate((posx-particleSize/2-screenOffset.x)/zoomDivider, (posy-particleSize/2-screenOffset.y)/zoomDivider);
		at.scale((double)particleSize/im.getWidth()/zoomDivider, (double)particleSize/im.getHeight()/zoomDivider);
		double dir = Math.atan2(spdy, spdx);
		at.rotate(dir, im.getWidth()/2, im.getHeight()/2);

		
		
		g2d.drawImage(im, at, ImageHandler.getInstance());
	}

}
